package com.dmooo.yxmmerchant.view.ui;

import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.common.util.SPUtils;
import com.dmooo.yxmmerchant.R;
import com.dmooo.yxmmerchant.base.BaseActivity;
import com.dmooo.yxmmerchant.common.Config;
import com.dmooo.yxmmerchant.util.NotificationUtil;
import com.suke.widget.SwitchButton;

import butterknife.BindView;
import butterknife.OnClick;

public class SettingActivity extends BaseActivity {
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.txt_phone)
    TextView txtPhone;
    @BindView(R.id.txt_email)
    TextView txtEmail;
    @BindView(R.id.btn_exit)
    Button btn_exit;
    @BindView(R.id.sb_check)
    SwitchButton sb_check;

    @Override
    protected int getLayout() {
        return R.layout.activity_setting;
    }

    @Override
    protected void initEventAndData() {
        tvTitle.setText("设置");
        if ("2".equals(SPUtils.get(mContext, Config.LOGIN_TYPE, "1"))) {
            findViewById(R.id.ll_set).setVisibility(View.GONE);
        }
        sb_check.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(SwitchButton view, boolean isChecked) {
                if (isChecked) {
                    if (!NotificationUtil.isNotificationEnabled(SettingActivity.this)) {
                        NotificationUtil.OpenNotificationSetting(SettingActivity.this, new NotificationUtil.OnNextLitener() {
                            @Override
                            public void onNext() {

                            }
                        });
                    } else {
                        SPUtils.put(SettingActivity.this, Config.IS_USER_OPEN_INFORM, "1");
                    }
                } else {
                    SPUtils.put(SettingActivity.this, Config.IS_USER_OPEN_INFORM, "0");
                }
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (!NotificationUtil.isNotificationEnabled(this)) {
            sb_check.setChecked(false);
        } else {
            if ("1".equals(SPUtils.get(this, Config.IS_USER_OPEN_INFORM, "0")))
                sb_check.setChecked(true);
        }
    }

    @Override
    protected void createPresenter() {

    }

    @OnClick({R.id.tv_left, R.id.ll_one, R.id.ll_two, R.id.ll_three, R.id.ll_four, R.id.ll_five, R.id.ll_six})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_left:
                finish();
                break;
//            case R.id.ll_one:
//                StartActivityUtil.startActivity(this, ChangePhoneActivity.class);
//                break;
//            case R.id.ll_two:
//                StartActivityUtil.startActivity(this, BindEmailActivity.class);
//                break;
//            case R.id.ll_three:
//                StartActivityUtil.startActivity(this, ChangePwdActivity.class);
//                break;
//            case R.id.ll_four:
//                StartActivityUtil.startActivity(this, SetDrawPwdActivity.class);
//                break;
//            case R.id.ll_five:
//                Bundle bundle = new Bundle();
//                bundle.putString("article_id", "7");
//                StartActivityUtil.startActivity(this, NewsDetailActivity.class, bundle);
//                break;
//            case R.id.ll_six:
//                StartActivityUtil.startActivity(this, FeedBackActivity.class);
//                break;
        }
    }
}
